<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="common :: header('WeiAdmin')"/>
    <link href="/admin/css/loader.css" rel="stylesheet"/>
    <link href="/admin/css/admin.css" rel="stylesheet"/>
    <style>

    </style>
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" lay-filter="settingForm" action="" onsubmit="return false">
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li class="layui-this">小程序配置</li>
                    <li>公众号配置</li>
                    <li>微信支付配置</li>
                </ul>

                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">

                        <div class="layui-form-item">
                            <label class="layui-form-label">appId</label>
                            <div class="layui-input-inline">
                                <input type="text" name="wxapp_appid" required lay-verify="required"
                                       placeholder="请输入appId" autocomplete="off" class="layui-input"
                                       th:value="${info.wxapp_appid}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">appSecret</label>
                            <div class="layui-input-inline">
                                <input type="text" name="wxapp_secret" required lay-verify="required"
                                       placeholder="请输入appSecret" autocomplete="off" class="layui-input"
                                       th:value="${info.wxapp_secret}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">小程序名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="wxapp_name" required lay-verify="required"
                                       placeholder="请输入小程序名称" autocomplete="off" class="layui-input"
                                       th:value="${info.wxapp_name}">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="pear-btn pear-btn-primary" lay-submit lay-filter="formDemo">保存</button>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab-item">
                        <div class="layui-form-item">
                            <label class="layui-form-label">appId</label>
                            <div class="layui-input-inline">
                                <input type="text" name="wxaccount_appid" required lay-verify="required"
                                       placeholder="请输入appId" autocomplete="off" class="layui-input"
                                       th:value="${info.wxaccount_appid}"
                                >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">AppSecret</label>
                            <div class="layui-input-inline">
                                <input type="text" name="wxaccount_secret" required lay-verify="required"
                                       placeholder="请输入AppSecret" autocomplete="off" class="layui-input"
                                       th:value="${info.wxaccount_secret}"
                                >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">公众号名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="wxaccount_name" required lay-verify="required"
                                       placeholder="请输入公众号名称" autocomplete="off" class="layui-input"
                                       th:value="${info.wxaccount_name}"
                                >
                            </div>
                        </div>
<!--                        <div class="layui-form-item">-->
<!--                            <label class="layui-form-label">接口地址</label>-->
<!--                            <div class="layui-input-inline">-->
<!--                                <input type="text" name="wxaccount_apiurl" required lay-verify="required"-->
<!--                                       placeholder="请输入appId" autocomplete="off" class="layui-input"-->
<!--                                >-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <div class="layui-form-item">-->
<!--                            <label class="layui-form-label">微信验证TOKEN</label>-->
<!--                            <div class="layui-input-inline">-->
<!--                                <input type="text" name="appId" required lay-verify="required"-->
<!--                                       placeholder="请输入appId" autocomplete="off" class="layui-input"-->
<!--                                >-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <div class="layui-form-item">-->
<!--                            <label class="layui-form-label">微信验证TOKEN</label>-->
<!--                            <div class="layui-input-inline">-->
<!--                                <input type="text" name="appId" required lay-verify="required"-->
<!--                                       placeholder="请输入appId" autocomplete="off" class="layui-input"-->
<!--                                >-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <div class="layui-form-item">-->
<!--                            <label class="layui-form-label">EncodingAESKey</label>-->
<!--                            <div class="layui-input-inline">-->
<!--                                <input type="text" name="appId" required lay-verify="required"-->
<!--                                       placeholder="请输入appId" autocomplete="off" class="layui-input"-->
<!--                                >-->
<!--                            </div>-->
<!--                        </div>-->
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="pear-btn pear-btn-primary" lay-submit lay-filter="formDemo">保存</button>
                            </div>
                        </div>
                    </div>

                    <div class="layui-tab-item ">

                        <div class="layui-form-item">
                            <label class="layui-form-label">微信商户号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="wxpay_mchid" required lay-verify="required"
                                       placeholder="请输入微信商户号" autocomplete="off" class="layui-input"
                                       th:value="${info.wxpay_mchid}"
                                >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">微信商户秘钥v2</label>
                            <div class="layui-input-inline">
                                <input type="text" name="wxpay_paysignv2" required lay-verify="required"
                                       placeholder="请输入微信商户秘钥v2" autocomplete="off" class="layui-input"
                                       th:value="${info.wxpay_paysignv2}"
                                >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">微信商户秘钥v3</label>
                            <div class="layui-input-inline">
                                <input type="text" name="wxpay_paysignv3" required lay-verify="required"
                                       placeholder="请输入微信商户秘钥v3" autocomplete="off" class="layui-input"
                                       th:value="${info.wxpay_paysignv3}"
                                >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">微信商户私钥证书key</label>
                            <div class="layui-input-inline">
                               <textarea name="wxpay_key" class="layui-textarea" th:text="${info.wxpay_key}"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">微信商户公钥证书cert</label>
                            <div class="layui-input-inline">
                                <textarea name="wxpay_cert" class="layui-textarea" th:text="${info.wxpay_cert}"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">支付回调地址</label>
                            <div class="layui-input-inline">
                                <input type="text" name="wxpay_notify" required lay-verify="required"
                                       placeholder="请输入回调地址" autocomplete="off" class="layui-input"
                                       th:value="${info.wxpay_notify}"
                                >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="pear-btn pear-btn-primary" lay-submit lay-filter="formDemo">保存</button>
                            </div>
                        </div>
                    </div>

                </div>

            </div>
        </form>
    </div>
</div>
</div>
<th:block th:include="common :: footer"/>
<script>
    layui.use(['form','laydate','jquery','upload'], function(){
      var form = layui.form;
      let $ = layui.jquery;
      var laydate = layui.laydate;
      laydate.render({
        elem: '#app_endtime'
      });
      //设置上传相关
      var upload = layui.upload;
      var uploadInst = upload.render({
        elem: '#ID-upload-demo-btn',
        url: '/admin/public/upload',
        done: function(res){
            debugger;
            if(res.code == 0){
                return layer.msg('上传失败');
            }
            $("#ID-upload-demo-img").attr("src",res.data.url);
            $("#thumb-input").val(res.data.url);
        }
      });
      form.on('submit(formDemo)', function(data){
          debugger;
          $.ajax({
                url: '/admin/plugin/updateWxpay',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            //parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            //parent.layui.table.reload("role-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
          return false;
      });
    });

</script>
</body>
</html>